package handler

import (
	"gitee.com/zyw0605688_admin/gozero/product_service/internal/logic/product"
	"gitee.com/zyw0605688_admin/gozero/product_service/internal/svc"
	"gitee.com/zyw0605688_admin/gozero/product_service/internal/types"
	"gitee.com/zyw0605688_admin/gozero/utils"
	"github.com/zeromicro/go-zero/rest/httpx"
	"net/http"
)

func ProductAddHandler(svcCtx *svc.ServiceContext) http.HandlerFunc {
	return func(w http.ResponseWriter, r *http.Request) {
		var req types.ProductAddRequest
		if err := httpx.Parse(r, &req); err != nil {
			httpx.Error(w, err)
			return
		}

		l := product.NewProductAddLogic(r.Context(), svcCtx)
		resp, err := l.ProductAdd(&req)
		utils.Response(w, resp, err) //②

	}
}
